﻿using Microsoft.AspNet.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinServer
{
    public partial class MyHub
    {
        public void Send(string msg)
        {
            string id = Context.ConnectionId;
            Clients.Client(id).Update($"好的，我已收到");
            //Clients.All.Update($"好的，我已收到");
            Program.frmServer.WriteLog($"{id}客户端发来消息：{msg}");
        }
        public void Send2(string msg)
        {
            string id = Context.ConnectionId;
            Clients.Client(id).Update($"好的，我已收到");
            //Clients.All.Update2($"好的，我已收到");
            Program.frmServer.WriteLog($"{id}客户端发来消息：{msg}");
        }

        public static void Broadcast(string name)
        {
            //通过全局变量GlobalHost的ConnectionManager获取一个hub的引用
            var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
            context.Clients.All.SayHello($"欢迎{name}上线_version1.1");
        }
    }
}
